
import type { OpenAI } from 'openai';
import type { APIPromise, RequestOptions } from 'openai/core.mjs';
import type { Stream } from 'openai/streaming.mjs';

interface ListResult {
  complete: boolean;
  cursor: string;
  keys: Array<ListKey>;
}
interface ListKey {
  key: string;
}
declare class KVNamespace {
  put(key: string, value: string | ArrayBuffer | ArrayBufferView | ReadableStream): Promise<void>;
  get(
    key: string,
    object?: { type: string }
  ): Promise<string | object | ArrayBuffer | ReadableStream>;
  delete(key: string): Promise<void>;
  list(config: { prefix?: string; limit?: number; cursor?: string }): Promise<ListResult>;
}

type AI = {
  chatCompletions(
    body: OpenAI.ChatCompletionCreateParamsNonStreaming,
    options?: RequestOptions
  ): APIPromise<string>;
  chatCompletions(
    body: OpenAI.ChatCompletionCreateParamsStreaming,
    options?: RequestOptions
  ): APIPromise<Stream<string>>;
};

export type { AI, KVNamespace };